<template>
  <div>
    路由所对应组件勾子
    <el-button @click="btnClick">跳转路由</el-button>
  </div>
</template>
<script>
export default {
  beforeRouteEnter(to, from, next) {
    // 不能使用this,它在beforeCreate前就有了
    console.log('beforeRouteEnter')
    next((vm) => {
      // vm就是当前组件的this
      console.log(vm)
    })
  },
  beforeRouteUpdate(to, from, next) {
    console.log('beforeRouteUpdate')
    next()
  },
  beforeRouteLeave(to, from, next) {
    console.log('beforeRouteLeave')
    next()
  },
  created() {
    console.log('created')
  },
  methods: {
    btnClick() {
      this.$router.push('/dashboard?id=' + Date.now())
    }
  }
}
</script>
<style></style>
